#include "goldmine.h"
#include "goldminestates.h"
#include <cassert>

GoldMine::GoldMine(int iID):BaseGameEntity(iID),
m_iGoldSupply(50),
m_iMaxGoldCapacity(50)
{
	EntityManager::Instance()->RegisterEntity(this);
	m_pStateMachine = new StateMachine<GoldMine>(this);

	m_pStateMachine->SetCurrentState(UnemptyState::Instance());
	m_pStateMachine->SetGlobalState(GoldMineGlobalState::Instance());
}

/*-------------------------------------------------------------------------------------------------------------*/
bool GoldMine::Initialize()
{
	if (!this->LoadIni("data/graphics/buildings/buildings.spr"))
	{
		return false;
	}

	SetFrame(2);

	return true;
}

/*-------------------------------------------------------------------------------------------------------------*/
GoldMine::~GoldMine()
{
	EntityManager::Instance()->RemoveEntity(this);
	delete m_pStateMachine;
}

/*-------------------------------------------------------------------------------------------------------------*/
void GoldMine::Update(float fDt)
{
	if(m_iGoldSupply == 0)
	{
		SetFrame(1);
	}

	Sprite::Update(fDt);
	m_pStateMachine->Update();
}

/*-------------------------------------------------------------------------------------------------------------*/
void GoldMine::Draw()
{
	Sprite::Draw();
}

/*-------------------------------------------------------------------------------------------------------------*/
bool GoldMine::IsGoldMineEmpty()
{
	if (m_iGoldSupply == 0)
	{
		return true;
	}
	return false;
}